<template>
  <Select v-model="tireRim" filterable clearable  placeholder="请选择直径">
    <Option
      v-for="item in list"
      :key="item.value"
      :label="item.text"
      :value="item.value.toString()">
    </Option>
  </Select>
</template>
<script>
import { getTireArr } from '@/util'
export default {
  props: {
    value: {
      type: [String, Number],
      default: null
    }
  },
  data() {
    return {
      list: [],
      tireRim: this.value
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData() {
      getTireArr().then(data => {
        this.list = data.data.tire_rim.filter(item => item.val).map(item => {
          return {
            value: item.val,
            text: item.name
          }
        })
      })
    }
  },
  watch: {
    value(val) {
      this.tireRim = val
    },
    tireRim(value) {
      this.tireRim = value
      this.$emit('input', value)
    }
  }
}
</script>